package cn.geekhalo.auth.domain;

import cn.geekhalo.common.support.AbstractEntity;
import com.google.common.collect.Sets;
import lombok.Data;

import javax.persistence.*;
import java.util.Set;

@Table(name = "tb_user")
@Entity
@Data
public class SysUser extends AbstractEntity {

    private String email;
    private String name;

    @ManyToMany(cascade = CascadeType.REMOVE,fetch = FetchType.LAZY)
    @JoinTable(name = "tb_user_role",joinColumns = @JoinColumn(name="user_id",referencedColumnName = "id"),inverseJoinColumns = @JoinColumn(name = "role_id",referencedColumnName = "id"))
    private Set<Role> roles = Sets.newHashSet();

    public SysUser(String email,String name){
        this.email = email;
        this.name = name;
    }
}
